<template>
    <div>
        <Button type="info" @click="changeType(1)">新闻</Button>
        <Button type="info" @click="changeType(2)">服装</Button>
        <Button type="info" @click="changeType(3)">电器</Button>
         <Tree :data="treeData" @on-select-change="onSelectChange"></Tree>
         <Button type="success">添加</Button>
    </div>
</template>
<script>
export default {
    data(){
        return{
            treeData:null,
            type:1
        };
    },
    methods:{
        changeType(type){
            this.type=type;
            this.getTree();
        },
        getTree(){
            this.axios({
                url:'http://localhost:3000/cate/list/'+this.type,
                method:'post'
            }).then(res=>{
                // console.log(res.data)
                this.treeData=res.data;
            });
        },
        onSelectChange(node){
            // console.log(node);
        }
    },
    mounted:function() {
            this.getTree();
    },
}
</script>

